var ajaxSer = (function(){
	
	return {
		
//		权限树接口
		permissionTree:function(callback){
			$.ajax({
				url : webroot+ "/menu/ztreePerData.do",
				data : {},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//权限新增
		permissionAdd:function(treeJson,callback,errorback){
			$.ajax({
				url : webroot+ "/Permssion/insertSelective.do",
				data : treeJson,
				type : 'POST',
				success : function(data) {
					callback(data);
				},
		        error:function(){
		        	errorback();
		        }
		  });
		},
		//权限修改前填充
		permissionEditPull:function(c_tIds,callback){
			$.ajax({
				url : webroot+ "/Permssion/selectById.do",
				data : {'Id': c_tIds},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//权限修改
		permissionEdit:function(treeJson,callback){
			 $.ajax({
					url : webroot+ "/Permssion/updateByPrimaryKeySelective.do",
					data : treeJson,
					type : 'POST',
					success : function(data) {
						callback(data);
					},
			        error:function(){
			        	errorback();
			        }
			  });
		},
		//权限删除
		permissionDel:function(perDelId,callback){
			 $.ajax({
					url : webroot+ "/Permssion/deleteByPrimaryKey.do",
					data : {"ids": perDelId},
					type : 'POST',
					success : function(data) {
						callback(data);
					}
			  });
		},
//		角色权限列表
		rolePermission:function(callback){
			$.ajax({
				url:webroot + '/menu/selectAllMenuAndPermission.do',
				data:{},
				type:"post",
				success:function(data){
					callback(data);
				}
			});
		},
		//角色保存
		rolePerSave:function(list,callback){
			$.ajax({
				url : webroot+ "/permissionRole/savePermissionByRoleKey.do",
				data : list,
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//角色新增
		roleAdd:function(treeJson,callback,errorback){
			$.ajax({
				url : webroot+ "/role/insert.do",
				data : treeJson,
				type : 'POST',
				success : function(data) {
					callback(data);
				},
		        error:function(){
		        	errorback();
		        }
		  });
		},
		//角色修改前填充
		roleEditPull:function(c_tIds,callback){
			$.ajax({
				url : webroot+ "/role/findById.do",
				data : {'id': c_tIds},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//角色修改
		roleEdit:function(treeJson,callback,errorback){
			$.ajax({
				url : webroot+ "/role/update.do",
				data : treeJson,
				type : 'POST',
				success : function(data) {
					callback(data);
				},
		        error:function(){
		        	errorback();
		        }
			});
		},
		//角色删除
		roleDel:function(delId,callback){
			$.ajax({
				url : webroot+ "/role/delete.do",
				data :{"ids": delId},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//角色选中分配权限
		roleToPermiss:function(id,callback){
			$.ajax({
				url : webroot+ "/permissionRole/selectPermissionByRoleKey.do",
				data : {'roleId':id},
				type : 'POST',
				success : function(obj) {
					callback(obj);
				}
			});
		},
//		字典数据初始化
		
		//字典左侧新增
		dictionLeftAdd:function(jsonList,callback,errorback){
			$.ajax({
				url : webroot+ "/dictionary/add.do",
				data : jsonList,
				type : 'POST',
				success : function(data) {
					callback(data);
				},
		        error:function(){
		        	errorback();
		        }
			});
		},
		//字典左侧修改前
		dictionLeftEditBefore:function(c_tIds,callback){
			$.ajax({
				url : webroot+ "/dictionary/selectById.do",
				data : {'id': c_tIds},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//字典左侧修改
		dictionLeftEdit:function(jsonList,callback,errorback){
			$.ajax({
				url : webroot+ "/dictionary/update.do",
				data : jsonList,
				type : 'POST',
				success : function(data) {
					callback(data);
				},
		        error:function(){
		        	errorback();
		        }
			});
		},
		//字典左侧修改
		dictionLeftIsSys:function(jsonList,callback){
			$.ajax({
				url : webroot+ "/dictionary/isSys.do",
				data : {type:jsonList},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//字典左侧删除
		dictionLeftDel:function(del_tIds,callback){
			$.ajax({
				url : webroot+ "/dictionary/del.do",
				data : {"ids": del_tIds},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//字典右侧新增
		dictionRightAdd:function(type, jsonList, callback,errorback){
			$.ajax({
				url : webroot+ "/dictionary/addDet.do?type="+type,
				data : jsonList,
				type : 'POST',
				success : function(data) {
					callback(data);
				},
		        error:function(){
		        	errorback();
		        }
			}); 
		},
		//字典右侧修改前
		dictionRightEditBefore:function(c_tIds, callback){
			$.ajax({
				url : webroot+ "/dictionary/selectByIdDet.do",
				data : {'id': c_tIds},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//字典右侧修改
		dictionRightEdit:function(jsonList, callback, errorback){
			$.ajax({
				url : webroot+ "/dictionary/updateDet.do",
				data : jsonList,
				type : 'POST',
				success : function(data) {
					callback(data);
				},
		        error:function(){
		        	errorback();
		        }
			});
		},
		//字典右侧删除
		dictionRightDel:function(del_tIds, callback){
			$.ajax({
				url : webroot+ "/dictionary/delDet.do",
				data : {"ids": del_tIds},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
//		用户管理角色初始化
		userRoleInit:function(callback){
			$.ajax({
				url : webroot+ "/role/selectAllDataList.do",
				data : {},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		//用户新增
		userAdd:function(jsonTree, callback, errorback){
			$.ajax({
				url : webroot+ "/user/insert.do",
				data : jsonTree,
				type : 'POST',
				success : function(data) {
					callback(data);
				},
				error:function(){
					errorback();
				}
		  });
		},
		//用户修改前填充
		userEditBefore:function(userid, callback, errorback){
			$.ajax({
				url:webroot + '/user/findUserDetail.do',
				type:"post",
				data:{'uId': userid},
				success:function(data){
					callback(data);
				}
			});
		},
		//用户修改
		userEdit:function(jsonTree, callback){
			$.ajax({
				url:webroot + '/user/update.do',
				type:"post",
				data: jsonTree,
				success:function(data){
					callback(data);
				},
				error:function(){
					errorback();
				}
			});
		},
		//用户删除
		userDel:function(ids, callback){
			$.ajax({
				url:webroot + '/user/updateState.do',
				type:"post",
				data:ids,
				success:function(data){
					callback(data);
				}
			});
		},
		//用户启用\禁用
		userOnOff:function(param, callback){
			$.ajax({
				url:webroot + '/user/updateState.do',
				type:"post",
				data:param,
				success:function(data){
					layer.msg(data.msg);
				}
			});
		},
		//新闻分类树
		newsTree:function(guid,callback){
			$.ajax({
				url:webroot + '/news/newsColumnTreeData.ajax',
				data : {'guid': guid},
				type:"post",
				success:function(data){
					callback(data);
				}
			});
		},
		//添加新闻分类
		newsColumnAdd:function(treeJson,callback){
			$.ajax({
				url : webroot+ "/news/saveNewsColumn.ajax",
				data : treeJson,
				type : 'POST',
				success : function(data) {
					callback(data);
				}
		  });
		},
		newsCloumnEditPull:function(id,callback){
			$.ajax({
				url : webroot+ "/news/searchNewsColumnById.ajax",
				data : {'columnId': id},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
		  });
		},
		newsCloumnEdit:function(treeJson,callback){
			$.ajax({
				url : webroot+ "/news/updateNewsCloumn.ajax",
				data : treeJson,
				type : 'POST',
				success : function(data) {
					callback(data);
				}
		  });
		},
		deleteNewsColumn:function(ids,callback){
			$.ajax({
				url : webroot+ "/news/deleteNewsColumn.ajax",
				data : {"ids":ids},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
		  });
		},
		deptOrEmpTree:function(checkedId,ifChecked,ifParentChecked,type,callback){
			$.ajax({
				url : webroot+ "/ztree/getZtreeData.ajax",
				data : {'checkedId':checkedId,'ifChecked':ifChecked,'ifParentChecked':ifParentChecked,'type':type},
				type : 'POST',
				success : function(data) {
					callback(data);
				}
			});
		},
		deptTree:function(callback){
			$.ajax({
				url:webroot + '/dep/deptTreeData.ajax',
				data : {},
				type:"post",
				success:function(data){
					callback(data);
				}
			});
		}
		
	}
})();